package Practice.Practice_02;

public class Demo01 {
    public static void main(String[] args){
        String str = "abc12der67df890dsafdafd_=@";
        int num1 = method1(str);
        int num2 = method2(str);
        System.out.println("数字有" + num1 + "个,字母有" + num2 + "个。");
    }

    public static int method1(String str){
        int sum = 0;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if(c >= '0' && c <= '9'){
                sum++;
            }
        }
        return sum;
    }

    public static int method2(String str){
        int sum;
        String s = str.replaceAll("[A-Za-z]","");
        sum = str.length() - s.length();
        return sum;
    }
}
